package org.leumasjaffe.initiativeTracker.event;


import java.awt.event.ActionEvent;

import javax.swing.Action;

import org.leumasjaffe.initiativeTracker.Constants;
import org.leumasjaffe.initiativeTracker.entity.Character;
import org.leumasjaffe.initiativeTracker.entity.PC;
import org.leumasjaffe.initiativeTracker.operator.CharacterLinker;
import org.leumasjaffe.initiativeTracker.view.InitiativeFrame;

import edu.wpi.heineman.xml.Message;
import edu.wpi.heineman.client.ServerAccess;

@SuppressWarnings("serial")
public class NullInitAction extends InitiativeTrackerAction implements Action {

	public NullInitAction (String text) {
		super(text);
	}
	
	@Override
	public void actionPerformed(ActionEvent e) {
		for (CharacterLinker cc : list.getList()) {
			Character c = cc.getCharacter();
			c.nullInit();
			if (c instanceof PC)
				((PC) c).nullTemp();
		}
		
		String xmlString = Message.requestHeader() + "<nullRequest game='" + Constants.id + "/></request>";
		ServerAccess.getInstance().sendRequest(new Message(xmlString));
		
		InitiativeFrame.getInstance().reset();
		gui.repaint();
	}
	
}